package com.yunkazaixian.syntelecom.service;

import com.yunkazaixian.syntelecom.entity.McSimDx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author guo
 */
@Service
public class RequestQueueService {

    private static final Logger log = LoggerFactory.getLogger(RequestQueueService.class);
    private final BlockingQueue<McSimDx> requestQueue = new LinkedBlockingQueue<>();

    public void submitTask(McSimDx task) {
        try {
            requestQueue.put(task);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        }
    }

    public McSimDx takeTask() throws InterruptedException {
        return requestQueue.take();
    }
    // 添加 getter 方法以允许外部访问 requestQueue
    public BlockingQueue<McSimDx> getRequestQueue() {
        return requestQueue;
    }
}
